package demo13.Practice01;

public class DuckSimulitor {
	public static void main(String[] args) {
		DuckSimulitor duckSimulitor = new DuckSimulitor();
		duckSimulitor.simultor();
	/*	开始统计鸭子叫
		绿头鸭呱呱叫
		橡皮鸭子吱吱叫
		红头鸭子呱呱叫
		大鹅叫
		鸭子叫了3次
*/
		
	}
	
 public void simultor(){
	 Quackable mallarDuck = new QuackCounter(new MallardDuck());
	 Quackable redhradDuck = new QuackCounter(new RedheadDuck());
	 Quackable rubberDuck = new QuackCounter(new RubberDuck());
	 Quackable gooseDuck = new GooseAdapter(new Goose());//大鹅不去装饰
	 System.out.println("开始统计鸭子叫");
	 simulate(mallarDuck);
	 simulate(rubberDuck);
	 simulate(redhradDuck);
	 simulate(gooseDuck);
	 System.out.println("鸭子叫了"+QuackCounter.getQuacks()+"次");
	 
 }
 
 public void simulate(Quackable duck){
	 duck.query();
	 	 
 }
}
